#include<iostream>
#include<vector>
#include<string.h>
#include<stdio.h>
using namespace std;

namespace v
{
	template<class t>
	class vector
	{
	public:
		typedef t* iterator;
		vector()
			:_start(nullptr)
			, _finsh(nullptr)
			, _end(nullptr)
		{

		}
		~vector()
		{
			delete[] _start;
			_start = _finsh = _end = nullptr;
		}
		void push_back(t d1)
		{
			size_t ca;

			if (capacity() == size())
			{
				if (capacity() == 0)
				{
					ca = 4;
				}
				else
				{
					ca = capacity() * 4;
				}
				//size_t ca = capacity() == 0 ? 4 : ca * 2;
				iterator tmp = new t[ca];
				if (_start)
				{
					memcpy(tmp, _start, sizeof(t) * size());
					delete[] _start;
				}
				_finsh = tmp + size();
				_start = tmp;
				_end = _start + ca;
			}
			*_finsh = d1;
			++_finsh;
		}
		void earse()
		{

		}
		void insert()
		{

		}
		iterator begin()
		{
			return _start;
		}
		iterator end()
		{
			return _finsh;
		}
		size_t capacity()
		{
			return _end - _start;
		}
		size_t size()
		{
			return _finsh - _start;
		}
		t& operator[](int i)
		{
			return _start[i];
		}
	private:
		iterator _start;
		iterator _finsh;
		iterator _end;
	};

}
int main()
{
	v::vector<int> d1;
	d1.push_back(1);
	d1.push_back(1);
	d1.push_back(1);
	d1.push_back(1);
	d1.push_back(1);
	for (size_t i = 0; i < d1.size(); i++)
	{
		cout << d1[i];
	}
	cout << endl;
	for (auto ch : d1)
	{
		cout << ch;
	}
	return 0;
}